package com.ksyun.camp.constant;


import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class AuthConstant {
    public static final Long STUDENT_ID = 20008L;

    public static  String LUA_ADD_MONEY = null;
    public static  String LUA_TRANSFER_MONEY = null;



    @EventListener(ApplicationReadyEvent.class)
    private void loadLua(){
        try {
            // 加载lua脚本
            ClassPathResource resource1 = new ClassPathResource("lua/addMoney.lua");
            LUA_ADD_MONEY = new String(resource1.getInputStream().readAllBytes());
            ClassPathResource resource2 = new ClassPathResource("lua/moneyTransfer.lua");
            LUA_TRANSFER_MONEY = new String(resource2.getInputStream().readAllBytes());
        }catch (Exception e){
            log.error("lua脚本加载失败{}", (Object) e.getStackTrace());
        }
    }

}
